Skip to content

Operations endpoints: version info #931

Open
gengur wants to merge 1 commit into
hyperledger:mainfrom
gengur:operations_versioninfo_handler
Open

Operations endpoints: version info #931
gengur wants to merge 1 commit into
hyperledger:mainfrom
gengur:operations_versioninfo_handler

Conversation

@gengur

@gengur gengur commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

issue: #45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an Operations /version endpoint and wires it into node startup logs/tests so fault-tolerance tests can discover and validate version info similarly to /metrics.

Changes:

  • Add /version handler initialization in common/operations.System and a helper to build the /version URL.
  • Log the /version endpoint URL on startup for router/consensus/batcher/assembler nodes.
  • Add test utilities and new fault-tolerance tests that fetch /version and assert the returned CommitSHA and Version.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
common/operations/system.go Registers and initializes a /version handler; adds a URL helper.
node/router/router.go Logs the /version endpoint URL at startup.
node/consensus/consensus.go Logs the /version endpoint URL at startup.
node/batcher/batcher.go Logs the /version endpoint URL at startup.
node/assembler/assembler.go Logs the /version endpoint URL at startup.
testutil/network_utils.go Adds helpers to capture /version URL and fetch/unmarshal version info.
test/faulttolerance/router_test.go Adds a fault-tolerance test validating router /version output.
test/faulttolerance/consensus_test.go Adds a fault-tolerance test validating consenter /version output.
test/faulttolerance/batcher_test.go Adds a fault-tolerance test validating batcher /version output.
test/faulttolerance/assembler_test.go Adds a fault-tolerance test validating assembler /version output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread common/operations/system.go
Comment thread testutil/network_utils.go
Comment on lines +82 to +104
func FetchVersionInfoValue(t *testing.T, re *regexp.Regexp, url string) *operations.VersionInfoHandler {
resp, err := http.Get(url)
require.NoError(t, err)

defer resp.Body.Close()

body, err := io.ReadAll(resp.Body)
require.NoError(t, err)

t.Log(string(body))

// Find all matches
matches := re.FindAllString(string(body), -1)

if len(matches) > 0 {
val := &operations.VersionInfoHandler{}
err := json.Unmarshal([]byte(matches[0]), val)
require.NoError(t, err)
return val
}

return nil
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@gengur gengur force-pushed the operations_versioninfo_handler branch 2 times, most recently from c809877 to 23619dc Compare June 21, 2026 08:14
@gengur gengur force-pushed the operations_versioninfo_handler branch from 23619dc to 7f31a97 Compare July 1, 2026 07:38
@tock-ibm tock-ibm force-pushed the operations_versioninfo_handler branch from 7f31a97 to 82be09d Compare July 1, 2026 14:22
@gengur gengur force-pushed the operations_versioninfo_handler branch from 82be09d to 80531a7 Compare July 2, 2026 10:10
}
// swagger:operation GET /version operations version
// ---
// summary: Returns the orderer or peer version and the commit SHA on which the release was created.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update: no peer here

Comment thread common/operations/system.go
if val == nil {
return false
}
return val.CommitSHA == metadata.CommitSHA && val.Version == metadata.Version

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please t.logf the version and build infor

require.GreaterOrEqual(t, testutil.FetchPrometheusMetricValue(t, blocksCountRe, url), 2)
}

// TestRunArmaNetworkAndGetAssemblerVersionInfo tests that the assembler's version info endpoint is up and returns the correct version information after the assembler is started.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to spin 4 different networks to test the /version service.
Start one network and test /healthz, /version in one test on all componets.

})
}

// TestRunArmaNetworkAndGetBatcherVersionInfo tests that the batcher's version info endpoint is up and returns the correct version information after the batcher is started.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to spin 4 different networks to test the /version service.
Start one network and test /healthz, /version in one test on all componets.

})
}

// TestRunArmaNetworkAndGetConsenterVersionInfo tests that the consenter's version info endpoint is up and returns the correct version information after the consenter is started.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to spin 4 different networks to test the /version service.
Start one network and test /healthz, /version in one test on all componets.

})
}

// TestRunArmaNetworkAndGetRouterVersionInfo tests that the router's version info endpoint is up and returns the correct version information after the router is started.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to spin 4 different networks to test the /version service.
Start one network and test /healthz, /version in one test on all componets.

}

func (s *System) initializeVersionInfoHandler() {
versionInfo := &VersionInfoHandler{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is coming from fabric-x-orderer/internal/cryptogen/metadata... not the right place IMO

@tock-ibm tock-ibm force-pushed the operations_versioninfo_handler branch from 80531a7 to 46baee3 Compare July 6, 2026 09:45
Signed-off-by: Genady Gurevich <genadyg@il.ibm.com>
@tock-ibm tock-ibm force-pushed the operations_versioninfo_handler branch from 46baee3 to bfcbf7b Compare July 6, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants